package com.david.bluetooth.util;

import android.media.MediaDataSource;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * MediaDataSource使用示例：https://blog.csdn.net/weixin_31034309/article/details/114851739
 * */
public class BTMediaDataSource extends MediaDataSource {

    BufferedInputStream stream;

    public BTMediaDataSource(InputStream inputStream) throws IOException {
        stream = new BufferedInputStream(inputStream);

    }

    @Override
    public long getSize() {
        return 0;

    }

    @Override
    public int readAt(long position,byte[] buffer,int offset,int size) throws IOException {
        return stream.read(buffer,offset,size);

    }

    @Override
    public void close() throws IOException {
        stream.close();

        stream = null;
    }
}
